package cn.afterturn.easypoi.test.excel.export.big;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import junit.framework.Assert;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Date;
import java.util.List;

/**
 * 当行大数据量测试
 *
 * @author JueYue
 * 2014年12月13日 下午3:42:57
 */
public class ExcelImportMsgClient {

    @Test
    public void test() throws Exception {

        ImportParams params = new ImportParams();
        params.setTitleRows(1);
        params.setHeadRows(3);
        long start = new Date().getTime();
        List<MsgClient> list = ExcelImportUtil.importExcel(
                new File("D:/home/excel/ExcelExportMsgClient.xlsx"), MsgClient.class, params);
        System.out.println(new Date().getTime() - start);
        //Assert.assertEquals(list.size(), 100);
        System.out.println(list.size());
        System.out.println(ReflectionToStringBuilder.toString(list.get(1)));


        ExportParams exportParams = new ExportParams("2412312", "测试", ExcelType.XSSF);
        exportParams.setFreezeCol(2);
        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, MsgClient.class, list);
        FileOutputStream fos = new FileOutputStream("D:/home/excel/ExcelExportMsgClient123.xlsx");
        workbook.write(fos);
        fos.close();
    }


}
